/**
 * @date 2016年1月3日 下午6:17:33
 * @version V1.0
 */
package MLDA_Process;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;


/**
 * @ClassName: ParallelTopicModel
 * @Description: TODO
 * @author ffftzh
 * @date 2016年1月3日 下午6:17:33
 *
 */
public class ParallelTopicModel {
    public static void gettheta(String path, int topicNUm) throws IOException {
        BufferedReader reader = Commons.IOUtil.getReader(path);
        BufferedWriter writer = Commons.IOUtil.getWriter(path + ".theta");
        reader.readLine();
        String line = null;
        int tag = -1;
        while ((line = reader.readLine()) != null) {
            String[] itemlist = line.split("\\s+");
            String[] writeLine = new String[topicNUm];
            for (int i = 0; i < itemlist.length; i++) {
                if (i < 2)
                    continue;
                if (i % 2 == 0) {
                    tag = Integer.parseInt(itemlist[i]);
                } else {
                    writeLine[tag] = itemlist[i];
                }
            }
            //	System.out.println(tag++);
            writer.write(Commons.utils.join(writeLine, " ") + "\n");
        }
        writer.close();

    }

    public static void main(String[] args) throws IOException {
        String rootPath = "D:\\javaEE\\MLDA\\data2\\QA_Q\\PTM\\";
        gettheta(rootPath + "yahoo_question.txt.pd.filter.final.10.ptm.theta", 100);

    }
}
